<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>登录</title>
    <meta charset="utf-8"/>
    <!--<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>-->
    <!--<meta name="viewport" content="width=device-width, initial-scale=1.0" />-->
    <!--<meta http-equiv="X-UA-Compatible" content="IE=edge">-->
    <!--<meta http-equiv="Cache-Control" content="no-store"/>-->
    <!--<meta http-equiv="Pragma" content="no-cache"/>-->
</head>
<body>
<div class="warp">

    <form name="loginform" id="loginform" method="post" action="${ctx}/j_spring_security_check">
        <div class="login_div login-box">
            <div class="title">麦宝管理系统<br>
                <small class="grey" style="font-size: 18px">请使用钉钉登录</small>
            </div>

            <div class="social-login center">
                <div class="col-xs-10">
                    <a class="btn btn-info" id="dingding_btn" style="line-height: 35px">
                        <img height="42px" src="${ctx}/assets/images/dingding_logo.png" alt=""/>
                    </a>
                </div>
            </div>
            <div class="row"></div>
            <div class="row center">
                <div id="login_container" style="margin-top: 20px"></div>
            </div>
            <ul class="login_ul">

            </ul>
        </div>
    </form>
<script src="./jquery-1.8.0.min.js"></script>
<script src="https://g.alicdn.com/dingding/dinglogin/0.0.2/ddLogin.js"></script>
<script type="text/javascript">

    $(function () {


        var appid = "dingoaxvx2b8epl38ibhnv";
        var redirect_url = "http://t.mattbaby.com/auth";

        var goto = encodeURIComponent("https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=" + appid + "&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=" + redirect_url);
        console.log(goto);
        var obj = DDLogin({
            id: "login_container",
            goto: goto,
            style: "",
            href: "",
            width: "300px",
            height: "300px"
        });

        var hanndleMessage = function (event) {
            var loginTmpCode = event.data; //拿到loginTmpCode后就可以在这里构造跳转链接进行跳转了
            alert(loginTmpCode);
            console.info(loginTmpCode);
            var origin = event.origin;
            /* window.location.href = "https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoaafjkfnrtknhapmlo&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=${ctx}/portal/no_login&loginTmpCode=" + loginTmpCode; */
        };
        if (typeof window.addEventListener != 'undefined') {
            window.addEventListener('message', hanndleMessage, false);
        } else if (typeof window.attachEvent != 'undefined') {
            window.attachEvent('onmessage', hanndleMessage);
        }

    });


    $(document).ready(function load() {
        $('#username').focus();
    });
</script>
</body>
</html>